package com.smart.daotest;

import com.smart.dao.LessonDao;
import com.smart.domain.Lesson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
import org.testng.annotations.Test;

import java.util.Date;

@ContextConfiguration("classpath*:/Room-context.xml")

@Rollback(false)

public class Testlesson extends AbstractTransactionalTestNGSpringContextTests {

   @Autowired
     private LessonDao lessonDao;


    @Test  //测试添加
    public  void testaddlesson(){
        Lesson lesson =new Lesson();
        lesson.setName("数学建模");
        Date date1 =new Date(118,5,18,8,30);
        Date date2=new Date(118,5,18,10,10);
        lesson.setNickName("建模");
        lesson.setStartTime(date1);
        lesson.setStopTime(date2);

        lessonDao.add(lesson);
    }

    @Test //测试删除
    public void testdelelesson(){
        Lesson lesson =new Lesson();
        lesson.setName("算法设计");
        lessonDao.deletelesson(lesson);
    }
    @Test //测试修改
    public void testupdatelesson(){
        Lesson lesson = new Lesson();
        lesson.setName("java程序设计");
        Date date1 =new Date(2018,5,18,2,00);
        Date date2=new Date(2018,5,18,3,40);
        lesson.setNickName("java");
        lesson.setStartTime(date1);
        lesson.setStopTime(date2);
        lessonDao.updatelesson(lesson);
    }



    @Test
    public void testquerylesson(){
        Lesson lesson =new Lesson();
        lesson.setName("java程序设计");
        lessonDao.querylesson(lesson);
    }
    @Test
    public  void testquerylistlesson(){
        Lesson lesson =new Lesson();
        lessonDao.querylistCompRoom();
    }
}
